const CompressionPlugin = require('compression-webpack-plugin')
module.exports = {
    publicPath: '/learn/',
    pages: {
        index: {
            entry: 'src/main.js'
        }
    },
    devServer: {
        host: '127.0.0.1',
        // host: '192.168.0.122',
        port: 8189,
        // https: true,
        proxy: {
            '/manage': {
                target: 'http://www.czytech.cn:8080/manage',
                changeOrigin: true,
                pathRewrite: {
                    '^/manage': ''
                }
            }
        }
    },
    css: {
        loaderOptions: {
            css: {},
            postcss: {
                plugins: [
                    require('postcss-px2rem')({
                        remUnit: 75
                    })
                ]
            }
        }
    },
    productionSourceMap: false,
    // 部署优化
    configureWebpack: {
        // 使用CDN
        externals: {
            vue: 'Vue',
            axios: 'axios',
            'vue-router': 'VueRouter',
            vuex: 'Vuex',
            ElementUi: 'element-ui'
        },
        plugins: [
            new CompressionPlugin({
                test: /\.js$|\.html$|\.css/, // 匹配文件
                threshold: 10240 // 对超过10k文件压缩
            })
        ]
    }
}
